package com.psp.bu.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.psp.bu.model.OrderBean;
import com.psp.bu.persist.dao.OrderDao;

@Repository
public class OrderImpl extends BaseImpl implements OrderDao {
	protected static final String NAME_SPACE = NAME_SPACE_HEADER + ".OrderMapper";

	@Override
	public OrderBean selectByOid(String oid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectByOid", oid);
	}

	@Override
	public int selectCount(String buid, String orderNo, int[] s) {
		Map<String, Object> where = new HashMap<>();
		where.put("orderNo", orderNo);
		where.put("state", s);
		where.put("buid", buid);
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectCount", where);
	}

	@Override
	public List<OrderBean> selectList(int page, int pageSize, String buid, String orderNo, int[] s) {
		Map<String, Object> where = new HashMap<>();
		where.put("start", page * pageSize);
		where.put("length", pageSize);
		where.put("orderNo", orderNo);
		where.put("state", s);
		where.put("buid", buid);
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectList", where);
	}

}
